//
// Created by 77873 on 2020/7/16 0016.
//

#ifndef FFMPEGPROJECT_MINEFFMPEG_H
#define FFMPEGPROJECT_MINEFFMPEG_H

#include "MineCallJava.h"
#include "MineAudio.h"



//#include "pthread.h"

extern "C" {
#include <libavformat/avformat.h>
#include <libavutil/time.h>
}


class MineFFmpeg {


public:
    MineCallJava *mineCallJava = NULL;
    const char *url = NULL;
    pthread_t decodeThread;


    AVFormatContext *pFormatCtx = NULL;
    MinePlayStatus *minePlayStatus = NULL;
    MineAudio *audio = NULL;


    pthread_mutex_t init_mutex;
    bool exit = false;//是否退出解码

    int duration = 0;//时长


    pthread_mutex_t seekMutex;

public:

    MineFFmpeg(MineCallJava *callJava, const char *musicUrl, MinePlayStatus *playStatus);

    ~MineFFmpeg();


    void parpared();

    //解码线程
    void decodeFFmpegThread();

    void start();

    void pause();

    void resume();

    void release();

    void seek(int64_t second);


    void setVolume(int percnet);

    void setMute(int mute);

    void setPitch(float pitch);

    void setSpeed(float speed);

    int getSampleRate();

    void startStopRecord(bool start);

    bool  curAudioPlay(int startTime,int endTime, bool showPcm);
};


#endif //FFMPEGPROJECT_MINEFFMPEG_H
